#ifndef __LIGHT_H__
#define __LIGHT_H__
#include <rtthread.h>
//#include "main.h"
#include <rtdevice.h>
#define PWM_DEV_NAME        "pwm2"  /* PWM设备名称 */
#define PWM_DEV_CHANNEL     2       /* PWM通道 */


/*
    period = 500000;    // 周期为0.5ms，单位为纳秒ns
    dir = 1;            // PWM脉冲宽度值的增减方向
    pulse = 0;          // PWM脉冲宽度值，单位为纳秒ns
    light_pulse_min = 0;
    light_pulse_max = period;
*/
#define period_init         10000    // 周期为0.5ms，单位为纳秒ns
#define dir_init            1           // PWM脉冲宽度值的增减方向
#define pulse_init          0        // PWM脉冲宽度值，单位为纳秒ns
#define light_pulse_min     pulse_init
#define light_pulse_max     period_init

#define light_pid_out_min     (-(light_pulse_max-light_pulse_min)/2)
#define light_pid_out_max     ((light_pulse_max-light_pulse_min)/2)

rt_err_t Light_open(void);

rt_err_t Light_set_lumen(rt_uint16_t lumen);

rt_err_t Light_set_pwm(rt_int32_t pwm_pulse);

rt_err_t Light_close(void);
#endif
